package cn.cloudplug.ui.view;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.widget.AppCompatImageView;
import android.view.View;
import android.view.ViewGroup;

import butterknife.BindView;
import cn.cloudplug.core.dialog.BaseFragmentDialog;
import cn.cloudplug.core.util.MyUtil;
import cn.cloudplug.ui.R;
import cn.cloudplug.ui.R2;

/**
 * Created by pc on 2018/2/4.
 */

public class SuspensionFrame extends BaseFragmentDialog {
    private ViewGroup mViewGroup;
    private Bitmap bgBitmap;
    private int mRadius;
    private OnResumeListener onResumeListener;

    public OnResumeListener getOnResumeListener() {
        return onResumeListener;
    }

    public void setOnResumeListener(OnResumeListener onResumeListener) {
        this.onResumeListener = onResumeListener;
    }

    @BindView(R2.id.iv_bg)
    AppCompatImageView iv_bg ;

    @Override
    protected Object setContent() {
        return R.layout.fragemnt_dialog_sf;
    }

    public ViewGroup getViewGroup() {
        return mViewGroup;
    }

    @Override
    protected void onBindView(Bundle savedInstanceState, View view) {
        mViewGroup= (ViewGroup) view;
        MyUtil.blur(bgBitmap,iv_bg,mRadius);
    }

    public void setBgBitmap(Bitmap bgBitmap, int radius) {
        this.bgBitmap = bgBitmap;
        this.mRadius = radius;
        if(mViewGroup!=null){
            MyUtil.blur(bgBitmap,iv_bg,mRadius);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if(onResumeListener!=null)onResumeListener.onResume();
    }

    @Override
    public void onStart() {
        super.onStart();
        if(onResumeListener!=null)onResumeListener.onStart();
    }

    @Override
    public void onPause() {
        super.onPause();
        if(onResumeListener!=null)onResumeListener.onPause();
    }

    @Override
    public void onStop() {
        super.onStop();
        if(onResumeListener!=null)onResumeListener.onStop();
    }

    public interface OnResumeListener{

        void onResume();

        void onStart();

        void onPause();

        void onStop();
    }
}
